// 道具相关API
import service from "../utils/request"

/**
 * 获取道具列表
 * @param {string} query 可选的搜索关键词
 * @param {string} category 可选的分类筛选
 * @returns {Promise} 道具列表数据
 */
export const getItemsList = (query = '', category = '') => {
    const params = {};
    if (query) params.query = query;
    if (category) params.category = category;
    return service.get('/items', { params });
}

/**
 * 按分类获取道具列表
 * @param {string} category 道具分类
 * @returns {Promise} 道具列表数据
 */
export const getItemsByCategory = (category) => {
    return service.get(`/items/category/${category}`);
}

/**
 * 搜索道具
 * @param {string} query 搜索关键词
 * @returns {Promise} 搜索结果
 */
export const searchItems = (query) => {
    return service.get('/items', { params: { query } });
}

/**
 * 获取精灵球列表
 * @param {string} query 可选的搜索关键词
 * @param {string} category 可选的分类筛选
 * @returns {Promise} 精灵球列表数据
 */
export const getPokeballsList = (query = '', category = '') => {
    const params = {};
    if (query) params.query = query;
    if (category) params.category = category;
    return service.get('/pokeballs', { params });
}

/**
 * 按分类获取精灵球列表
 * @param {string} category 精灵球分类
 * @returns {Promise} 精灵球列表数据
 */
export const getPokeballsByCategory = (category) => {
    return service.get(`/pokeballs/category/${category}`);
}

/**
 * 搜索精灵球
 * @param {string} query 搜索关键词
 * @returns {Promise} 搜索结果
 */
export const searchPokeballs = (query) => {
    return service.get('/pokeballs', { params: { query } });
}

/**
 * 获取模拟道具数据（用于后端API不可用时的备用方案）
 * @returns {Promise} 模拟道具列表数据
 */
export const getMockItemsList = () => {
    return new Promise((resolve) => {
        setTimeout(() => {
            const mockItems = [
                {
                    id: 1,
                    itemId: "pokeball",
                    itemName: '精灵球',
                    category: 'standard',
                    description: '用于捕捉野生宝可梦的球。设计简洁，使用方便。',
                    imageUrl: '/images/items/pokeball.png'
                },
                {
                    id: 2,
                    itemId: "great-ball",
                    itemName: '超级球',
                    category: 'standard',
                    description: '比精灵球性能更好的球。提高了捕获野生宝可梦的成功率。',
                    imageUrl: '/images/items/great-ball.png'
                },
                {
                    id: 3,
                    itemId: "ultra-ball",
                    itemName: '高级球',
                    category: 'standard',
                    description: '性能非常好的球。能够更容易地捕获野生宝可梦。',
                    imageUrl: '/images/items/ultra-ball.png'
                },
                {
                    id: 4,
                    itemId: "master-ball",
                    itemName: '大师球',
                    category: 'master',
                    description: '最高性能的球。能够100%捕获任何野生宝可梦。',
                    imageUrl: '/images/items/master-ball.png'
                },
                {
                    id: 5,
                    itemId: "potion",
                    itemName: '伤药',
                    category: 'field',
                    description: '喷雾式药物。能让宝可梦回复20HP。',
                    imageUrl: '/images/items/potion.png'
                },
                {
                    id: 6,
                    itemId: "super-potion",
                    itemName: '好伤药',
                    category: 'field',
                    description: '喷雾式药物。能让宝可梦回复50HP。',
                    imageUrl: '/images/items/super-potion.png'
                },
                {
                    id: 7,
                    itemId: "hyper-potion",
                    itemName: '厉害伤药',
                    category: 'field',
                    description: '喷雾式药物。能让宝可梦回复200HP。',
                    imageUrl: '/images/items/hyper-potion.png'
                },
                {
                    id: 8,
                    itemId: "max-potion",
                    itemName: '全满药',
                    category: 'field',
                    description: '喷雾式药物。能让宝可梦回复全部HP。',
                    imageUrl: '/images/items/max-potion.png'
                },
                {
                    id: 9,
                    itemId: "revive",
                    itemName: '活力碎片',
                    category: 'field',
                    description: '能让失去战斗能力的宝可梦复活，并回复一半HP。',
                    imageUrl: '/images/items/revive.png'
                },
                {
                    id: 10,
                    itemId: "max-revive",
                    itemName: '活力块',
                    category: 'field',
                    description: '能让失去战斗能力的宝可梦复活，并完全回复HP。',
                    imageUrl: '/images/items/max-revive.png'
                },
                {
                    id: 11,
                    itemId: "ether",
                    itemName: 'PP恢复剂',
                    category: 'field',
                    description: '能让宝可梦已经学会的1个招式回复10PP。',
                    imageUrl: '/images/items/ether.png'
                },
                {
                    id: 12,
                    itemId: "max-ether",
                    itemName: 'PP多项恢复剂',
                    category: 'field',
                    description: '能让宝可梦已经学会的全部招式各自回复10PP。',
                    imageUrl: '/images/items/max-ether.png'
                },
                {
                    id: 13,
                    itemId: "full-heal",
                    itemName: '万能药',
                    category: 'field',
                    description: '能治愈宝可梦的所有异常状态的药。',
                    imageUrl: '/images/items/full-heal.png'
                },
                {
                    id: 14,
                    itemId: "antidote",
                    itemName: '解毒药',
                    category: 'field',
                    description: '能治愈宝可梦中毒状态的药。',
                    imageUrl: '/images/items/antidote.png'
                },
                {
                    id: 15,
                    itemId: "paralyze-heal",
                    itemName: '解麻药',
                    category: 'field',
                    description: '能治愈宝可梦麻痹状态的药。',
                    imageUrl: '/images/items/paralyze-heal.png'
                },
                {
                    id: 16,
                    itemId: "tm01",
                    itemName: '技能机器01',
                    category: 'training',
                    description: '记录着招式的光盘。能让宝可梦学会百万吨重拳。',
                    imageUrl: '/images/items/tm.png'
                },
                {
                    id: 17,
                    itemId: "tm02",
                    itemName: '技能机器02',
                    category: 'training',
                    description: '记录着招式的光盘。能让宝可梦学会一字斩。',
                    imageUrl: '/images/items/tm.png'
                },
                {
                    id: 18,
                    itemId: "tm06",
                    itemName: '技能机器06',
                    category: 'training',
                    description: '记录着招式的光盘。能让宝可梦学会剧毒。',
                    imageUrl: '/images/items/tm.png'
                },
                {
                    id: 19,
                    itemId: "moon-stone",
                    itemName: '月之石',
                    category: 'evolution',
                    description: '某些宝可梦的进化之石。漆黑如夜空般的石头。',
                    imageUrl: '/images/items/moon-stone.png'
                },
                {
                    id: 20,
                    itemId: "fire-stone",
                    itemName: '火之石',
                    category: 'evolution',
                    description: '某些宝可梦的进化之石。触摸后感觉温暖的橙色石头。',
                    imageUrl: '/images/items/fire-stone.png'
                },
                {
                    id: 21,
                    itemId: "water-stone",
                    itemName: '水之石',
                    category: 'evolution',
                    description: '某些宝可梦的进化之石。透明的蓝色美丽石头。',
                    imageUrl: '/images/items/water-stone.png'
                },
                {
                    id: 22,
                    itemId: "thunder-stone",
                    itemName: '雷之石',
                    category: 'evolution',
                    description: '某些宝可梦的进化之石。带有电气的黄色石头。',
                    imageUrl: '/images/items/thunder-stone.png'
                },
                {
                    id: 23,
                    itemId: "leaf-stone",
                    itemName: '叶之石',
                    category: 'evolution',
                    description: '某些宝可梦的进化之石。散发着森林气息的绿色石头。',
                    imageUrl: '/images/items/leaf-stone.png'
                },
                {
                    id: 24,
                    itemId: "rare-candy",
                    itemName: '奇异甜食',
                    category: 'other',
                    description: '西尔佛公司开发的人工甜味料。宝可梦非常喜欢。',
                    imageUrl: '/images/items/rare-candy.png'
                },
                {
                    id: 25,
                    itemId: "bicycle",
                    itemName: '自行车',
                    category: 'other',
                    description: '折叠式自行车。比跑步快2倍，但无法钓鱼。',
                    imageUrl: '/images/items/bicycle.png'
                },
                {
                    id: 26,
                    itemId: "old-rod",
                    itemName: '钓鱼竿',
                    category: 'other',
                    description: '破旧的钓鱼竿。只能钓到弱小的宝可梦。',
                    imageUrl: '/images/items/old-rod.png'
                },
                {
                    id: 27,
                    itemId: "good-rod",
                    itemName: '好钓竿',
                    category: 'other',
                    description: '不错的钓鱼竿。能钓到各种宝可梦。',
                    imageUrl: '/images/items/good-rod.png'
                },
                {
                    id: 28,
                    itemId: "super-rod",
                    itemName: '厉害钓竿',
                    category: 'other',
                    description: '最好的钓鱼竿。能钓到稀有的宝可梦。',
                    imageUrl: '/images/items/super-rod.png'
                },
                {
                    id: 29,
                    itemId: "oran-berry",
                    itemName: '橙橙果',
                    category: 'other',
                    description: '营养丰富的树果。能让宝可梦回复10HP。',
                    imageUrl: '/images/items/oran-berry.png'
                },
                {
                    id: 30,
                    itemId: "pecha-berry",
                    itemName: '桃桃果',
                    category: 'other',
                    description: '甜美的树果。能治愈宝可梦的麻痹状态。',
                    imageUrl: '/images/items/pecha-berry.png'
                }
            ]

            resolve({
                flag: true,
                data: mockItems,
                msg: "模拟道具数据加载成功"
            });
        }, 500)
    })
} 